package com.hnhegui.backend.order.api;

import com.hnhegui.backend.entity.PageResult;
import com.hnhegui.backend.entity.Result;
import com.hnhegui.backend.order.dto.request.AdminOrdersRequestDTO;
import com.hnhegui.backend.order.dto.request.CreateOrderRequestDTO;
import com.hnhegui.backend.order.dto.request.OrderDocumentPageRequestDTO;
import com.hnhegui.backend.order.dto.request.PayOrderRequestDTO;
import com.hnhegui.backend.order.dto.request.PaymentOrderCallbackRequestDTO;
import com.hnhegui.backend.order.dto.response.CreateOrderResponseDTO;
import com.hnhegui.backend.order.dto.response.OrderDocumentResponseDTO;
import com.hnhegui.backend.order.dto.response.PayOrderResponseDTO;
import com.hnhegui.backend.order.dto.response.PaymentOrderCallbackResponseDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(value = "hnhegui-backend-order", path = "/api/orders", contextId = "orderRestApi" )
public interface OrderRestApi {

    @PostMapping("/create")
    Result<CreateOrderResponseDTO> createOrder(@Validated @RequestBody CreateOrderRequestDTO request);

    /**
     * 用户订单查询
     */
    @PostMapping("/my")
    Result<PageResult<OrderDocumentResponseDTO>> getMyOrders(@RequestBody OrderDocumentPageRequestDTO request);

    /**
     * 订单详情查询
     */
    @GetMapping("/{orderId}")
    Result<OrderDocumentResponseDTO> getOrderDetail(@PathVariable String orderId);

    /**
     * 管理端订单查询（支持多条件组合查询）
     * @param request 查询参数
     * @return 订单分页结果
     */
    @PostMapping("/admin")
    Result<PageResult<OrderDocumentResponseDTO>> getAdminOrders(@RequestBody AdminOrdersRequestDTO request);

    /**
     * 订单支付
     */
    @PostMapping("/pay")
    Result<PayOrderResponseDTO> payOrder(@RequestBody PayOrderRequestDTO request);

    /**
     * 支付回调（模拟）
     */
    @PostMapping("/callback")
    Result<PaymentOrderCallbackResponseDTO> paymentCallback(@RequestBody PaymentOrderCallbackRequestDTO request);
}
